import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s1=sc.nextLine();
        String s2=sc.nextLine();
        String s3=sc.nextLine();
        String[] arr=s1.split(" ");
        for(int i=0;i<arr.length;i++)
        {
            if(arr[i].equals(s2))
                arr[i]=s3;
            if(i==0)
                System.out.print(arr[i]);
            else
                System.out.print(" "+arr[i]);
        }

    }
}
